package com.ankur.calllogger;

import java.io.IOException;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MailHandlerServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3879076857885496500L;

	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		Properties props = new Properties();
		Session session = Session.getDefaultInstance(props, null);
		try {
			MimeMessage message = new MimeMessage(session, req.getInputStream());
			message.setFrom(new InternetAddress("forward@detailedcalllogger.appspotmail.com"));
			message.setRecipient(Message.RecipientType.TO, new InternetAddress("ankurpshah@gmail.com"));
			Transport.send(message);
		} catch (MessagingException e) {
			e.printStackTrace();
		}
	}
}
